{layout name="public/layout" /}
		{include file='yxnavbar'}
<link rel="stylesheet" href="{$_G['URL']['APP_CSS']}back.css">
	<style type="text/css">
	.order-detail-info>div{margin-bottom:10px; padding-left:15px;}
	.page-trade-order h4{font-size:14px; font-weight:700;}
	.page-trade-order .form-group{margin-bottom:0;}
	.page-trade-order .form-group .control-label{font-weight:normal; color:#999;}
	.page-trade-order .order-infos{border-right:1px solid #ddd;}
	.page-trade-order .parting-line{height:1px;border-top:1px dashed #e5e5e5; margin:3px 0;}
	.page-trade-order .order-state{padding-left:40px; position:relative; margin:20px 0 40px;}
	.page-trade-order .order-state>span{color:#07d; position:absolute; left:0; top:5px; font-size:25px; display:inline-block; width:30px; height:30px; border:1px solid #07d; border-radius:30px; text-align:center; line-height:30px;}
	#close-order ul li{padding:5px 15px; cursor:pointer;}
	#close-order ul li:hover{background:#eee;}
	.fix a.js-order-edit-address{display:none; color:red;}
	.fix:hover a.js-order-edit-address{display:inline;}
	.page-trade-order .col-sm-9{word-break: break-word; overflow:hidden;}
	.table-log>tbody>tr>td{border-top:none;}
</style>
<script type="text/javascript">
function submitForm(){
    var form = document.getElementById("myform");
    form.submit();
}
</script>
{if $op == 'display'}
<div class="main">
	<div class="panel panel-info">
		<div class="panel-heading">筛选  <span id="btinfo">{$total}条</span></div>
		<div class="panel-body">
			<form id = "myform" action="./index.php" method="get" class="form-horizontal" role="form">
				<input type="hidden" name="c" value="site" />
				<input type="hidden" name="a" value="entry" />
				<input type="hidden" name="m" value="{$_P['m']}" />
				<input type="hidden" name="do" value="{$do}" />
				<input type="hidden" name="paystate" value="{$paystate}" />
				<div class="form-group">
					<label class="col-xs-12 col-sm-1 col-md-1 control-label">范围</label>
					<div class="col-sm-8 col-xs-8 col-md-8">
						<div class="btn-group">
							<a href="{php echo filter_url('type:-1');}" class="btn {if $type == -1}btn-primary{else}btn-default{/if}">不限 <span style="color: #ff0000">{$gsumall}</span></a>
							<a href="{php echo filter_url('type:0');}" class="btn {if $type == 0}btn-primary{else}btn-default{/if}">团长 <span style="color: #ff0000">{$gsum0}</span></a>
							<a href="{php echo filter_url('type:1');}" class="btn {if $type == 1}btn-primary{else}btn-default{/if}">团员 <span style="color: #ff0000">{$gsum1}</a>
							<a href="{php echo filter_url('type:9');}" class="btn {if $type == 9}btn-primary{else}btn-default{/if}">单买 <span style="color: #ff0000">{$gsum9}</a>
							{if $_G['isSuperAdmin']}
								{if $gsum2 != 0}
								<a href="{php echo filter_url('type:2');}" class="btn {if $type == 2}btn-primary{else}btn-default{/if}">分销红包 <span style="color: #ff0000">{$gsum2}</a>
								{/if}
								{if $gsum4 != 0}
								<a href="{php echo filter_url('type:4');}" class="btn {if $type == 4}btn-primary{else}btn-default{/if}">转发红包 <span style="color: #ff0000">{$gsum4}</a>
								{/if}
								{if $gsum5 != 0}
								<a href="{php echo filter_url('type:5');}" class="btn {if $type == 5}btn-primary{else}btn-default{/if}">阅读红包 <span style="color: #ff0000">{$gsum5}</a>
								{/if}
								{if $gsum7 != 0}
								<a href="{php echo filter_url('type:7');}" class="btn {if $type == 7}btn-primary{else}btn-default{/if}">摇一摇红包 <span style="color: #ff0000">{$gsum7}</a>
								{/if}
								{if $gsum6 != 0}
								<a href="{php echo filter_url('type:6');}" class="btn {if $type == 6}btn-primary{else}btn-default{/if}">员工提成 <span style="color: #ff0000">{$gsum6}</a>
								{/if}
							{/if}
						</div>
					</div>
					{if count($themelist)>1}
						<div class="col-sm-3 col-xs-3 col-md-3">
							 <select onchange="submitForm();" class="form-control" name="themeid">
	                   		{loop $themelist $row}
				         		<option value="{$row['id']}" {if $themeid == $row['id'] }selected="selected"{/if}>{$row['id']} - {php echo mb_substr($row['title'],0,8,'utf-8');}</option>
				       		{/loop}
				     		 </select>
			 			</div>
					{else}
						<input type="hidden" name="themeid" value="{$themeid}" /> 
					{/if}
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-1 control-label">支付状态</label>
					<div class="col-sm-9 col-xs-9 col-md-9">
						<div class="btn-group">
							<a href="{php echo filter_url('paystate:-10');}" class="btn {if $paystate == -10}btn-primary{else}btn-default{/if}">不限<span style="color: #ff0000">{$gsum10}</span></a>
							<a href="{php echo filter_url('paystate:0');}" class="btn {if $paystate == 0}btn-primary{else}btn-default{/if}">未支付<span style="color: #ff0000">{$gsum11}</span></a>
							<a href="{php echo filter_url('paystate:1');}" class="btn {if $paystate == 1}btn-primary{else}btn-default{/if}">已支付<span style="color: #ff0000">{$gsum12}</span></a>
							<a href="{php echo filter_url('paystate:-1');}" class="btn {if $paystate == -1}btn-primary{else}btn-default{/if}">已退款<span style="color: #ff0000">{$gsum13}</span></a>
						</div>
					</div>
				</div>
				{if $_G['isSuperAdmin']}
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-1 control-label">核验状态</label>
					<div class="col-sm-9 col-xs-9 col-md-9">
						<div class="btn-group">
							<a href="{php echo filter_url('ispay:-10');}" class="btn {if $ispay == -10}btn-primary{else}btn-default{/if}">不限<span style="color: #ff0000">{$gsum12}</span></a>
							<a href="{php echo filter_url('ispay:-9');}" class="btn {if $ispay == -9}btn-primary{else}btn-default{/if}">未核验<span style="color: #ff0000">{$gsum24}</span></a>
							<a href="{php echo filter_url('ispay:-8');}" class="btn {if $ispay == -8}btn-primary{else}btn-default{/if}">已核验<span style="color: #ff0000">{$gsum20}</span></a>
							<a href="{php echo filter_url('ispay:-1');}" class="btn {if $ispay == -1}btn-primary{else}btn-default{/if}">正常<span style="color: #ff0000">{$gsum21}</span></a>
							<a href="{php echo filter_url('ispay:0');}" class="btn {if $ispay == 0}btn-primary{else}btn-default{/if}">未付<span style="color: #ff0000">{$gsum22}</span></a>
							<a href="{php echo filter_url('ispay:1');}" class="btn {if $ispay == 1}btn-primary{else}btn-default{/if}">异常<span style="color: #ff0000">{$gsum23}</span></a>
							{if $gsum25>0}
							<a href="{php echo filter_url('ispay:-11');}" class="btn {if $ispay == -11}btn-primary{else}btn-default{/if}">原后台<span style="color: #ff0000">{$gsum25}</span></a>
							{/if}
						</div>
					</div>
				</div>
				{/if}
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-1 control-label">下单时间</label>
					<div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
						{php echo view_form_field_daterange('createtime', array('start'=>date('Y-m-d H:i:s',$starttime),'end'=>date('Y-m-d H:i:s',$endtime)), true);}						
					</div>
				</div>
				<div class="form-group clearfix">
					<label class="col-xs-12 col-sm-3 col-md-1 control-label">用户信息</label>
					<div class="col-sm-3 col-xs-3 col-md-3">
						<input class="form-control" name="keyword" placeholder="可输入昵称、用户名、手机号、交易单号" type="text" value="{$_P['keyword']}">
					</div>
					<div class="col-sm-5 col-lg-5 col-md-5 col-xs-6">
						<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
						<input type="hidden" name="__token__" value="{$Request.token}"/>
						{if $_G['isSuperAdmin']}
						<a href="{php echo createWebUrl('order',array('op'=>'checkpaylist','themeid'=>$themeid));}" onclick="if(!confirm('每次较验100个，大约需要1分钟，请稍后')) return false;" class="btn btn-default">定单较验</a>
						<a href="{php echo createWebUrl('order',array('op'=>'checkunpaylist','themeid'=>$themeid));}" onclick="if(!confirm('每次较验100个，大约需要1分钟，请稍后')) return false;" class="btn btn-default">未支付定单较验</a>
						<a href="{php echo createWebUrl('order',array('op'=>'checkpaylistcz','themeid'=>$themeid));}" onclick="if(!confirm('确定重新较验吗')) return false;"  class="btn btn-default">重置较验</a>
						{/if}
					</div>
				</div>
			</form>
		</div>
	</div>
<!-- 		<ul class="order-nav order-nav-tabs">
			<li {if $status == -1}class="active"{/if}><a href="{php echo filter_url('status:-1');}">所有定单</a></li>
			<li {if $status == 0}class="active"{/if}><a href="{php echo filter_url('status:0');}">未核销定单</a></li>
			<li {if $status == 1}class="active"{/if}><a href="{php echo filter_url('status:1');}">已核销定单</a></li>
		</ul> -->
		<div class="panel panel-default">
			<div class="panel-body table-responsive" style="overflow:inherit">
				<table class="table table-hover">
					<thead class="navbar-inner">
						<tr>
							<th width="50">交易ID</th>
							<th>头像</th>
							<th>昵称</th>
							<th>姓名</th>
							<th>电话</th>
							<th>定单类型</th>
							<th>支付方式</th>
							<th>支付状态</th>
							<th>定单价格</th>
							<th>实际支付</th>
							<th style="width:60px;">商户定单号</th>
							<th >下单时间</th>
							{if $_G['isSuperAdmin']}
							<th >核验时间</th>
							<th >是否正常</th>
							{/if}
							<th style="width:50px; text-align:right;">详情</th>
						</tr>
					</thead>
					<tbody>
						{loop $list $row}
						<tr>
							<td><b>{php echo $row['id']+6000;}</b></td>
							<td>
								<img src="{php echo tomedia($row['avatar']);}" width="28" style="bsection-radius: 3px;">
							</td>
							<td>
								{$row['nickname']}
							</td>
							<td>
								{$row['username']}
							</td>
							<td>
								{$row['mobile']}
							</td>
							<td>
							{if $row['ordertype']=='0'}
									<span class="label label-success">团长</span>
							{elseif $row['ordertype']=='1'}
									<span class="label label-primary">团员</span>
							{elseif $row['ordertype']=='2'}
									<span class="label label-danger">分销奖励</span>
							{elseif $row['ordertype']=='4'}
									<span class="label label-danger">转发红包</span>
							{elseif $row['ordertype']=='7'}
									<span class="label label-danger">摇一摇红包</span>
							{elseif $row['ordertype']=='6'}
									<span class="label label-danger">员工提成</span>
							{elseif $row['ordertype']=='scanpay'}
									<span class="label label-primary">扫码付</span>
							{elseif $row['ordertype']=='99'}
									<span class="label label-warning">分销提现</span>
									{elseif $row['ordertype']=='9'}
									<span class="label label-warning">单买</span>
									{elseif $row['ordertype']=='8'}
									<span class="label label-warning">补余款</span>
									{else}
									<span class="label label-info">其他</span>
									{/if}
							</td>
							
							<td>
								{if $row['paystate']==0}
									<span class="label label-warning">未支付</span>
								{else}
									{if $row['type']=='credit'}
									<span class="label label-info">余额支付</span>
									{elseif $row['type']=='wechat'}
									<span class="label label-success">微信支付</span>
									{elseif $row['type']=='wxapp'}
									<span class="label label-warning">小程序</span>
									{elseif $row['type']=='delivery'}
									<span class="label label-primary">货到付款</span>
									{elseif $row['type']=='cash'}
									<span class="label label-primary">现金付款</span>
									{else}
									<span class="label label-warning">其他方式</span>
									{/if}
									
									{if $row['tiaozhuan']==1}
									<br>
									<span class="label label-info">原后台支付</span>
									{/if}
								{/if}
								
							</td>
							<td>
								{if $row['paystate']==0}
									<span class="label label-warning">未支付</span>
								{elseif $row['paystate']==-1}
									<span class="label label-danger">已退款</span>
								{else}
									<span class="label label-success">已支付</span>
								{/if}
								
							</td>
							<td>
								<span class="label label-info">{$row['orderfee']}</span>
							</td>
							<td><span class="label label-primary">{$row['realfee']}</span></td>
							<td style="font-size: 10px;word-break:break-all; ">{php echo  $row['ordertype']=='2'?$row['ordersn']:$row['uniontid'];}</td>
							<td  style="font-size: 10px;max-width: 100px;">{php echo date('Y-m-d',$row['addtime']);}<br>{php echo date('H:i:s',$row['addtime']);}{if !empty($system['wxapp'])}<br>{php echo $system['wxapp']==$row['uniacid']?'小程序':'H5链接';}{/if}</td>
							{if $_G['isSuperAdmin']}
								{if !empty($row['checktime'])}
									<td >{php echo date('Y-m-d H:i:s', $row['checktime']);}</td>
									<td >
										{if $row['ispay']== -1 }
											<span class='label label-success'>正常</span>
										{elseif $row['ispay']== 0 }
											<span class='label label-warning'>未支付</span>
										{else}
											<span class='label label-danger'>实际{$row['ispay']}</span>
										{/if}
									</td>
								{else}
									<td ></td>
									<td ></td>
								{/if}
							{/if}
							<td style="text-align:right; overflow:visible;">
								{if $_G['isSuperAdmin']}
								<div class="btn-group">
								<a href="{php echo createWebUrl($do, array('op' => 'checkpay','themeid'=>$themeid, 'id' => $row['id']));}" class="btn btn-success btn-sm" style="width: 35px" title="核对定单" data-toggle="tooltip" data-placement="top"><i class="fa fa-gavel"> </i></a>		
								</div>
								{/if}
								{if $row['status']==0}
								<div class="btn-group">
								<a href="{php echo createWebUrl($do, array('op' => 'delete','themeid'=>$themeid, 'id' => $row['id']));}" class="btn btn-danger btn-sm" style="width: 35px" onclick="if(!confirm('确定删除该定单吗')) return false;"  title="删除定单" data-toggle="tooltip" data-placement="top"><i class="fa fa-times"> </i></a>		
								</div>				
								{/if}
							</td>
						</tr>
						{/loop}
					
					</tbody>
				</table>
			</div>
		</div>
		{$pager}
</div>

<script type="text/javascript">








	$('#selectall').click(function(){
		$('#form-order :checkbox').prop('checked', $(this).prop('checked'));
	});

	$('.btn-order').click(function(){
		if($('#form-order :checkbox:checked').length == 0) {
			u.message('请选择定单', '', 'error');
			return false;
		}
		if(!confirm('确定修改定单的状态吗')) {
			return false;
		}
		$('#form-order #status').val($(this).data('id'));
		$('#form-order #type').val($(this).data('type'));
		$('#form-order').submit();
		return false;
	});

	$('.btn-cancel').click(function(e){
		var pay = $(this).data('pay');
		var pay_type = $(this).data('pay-type');
		var tip = '确定取消定单吗';
		if(pay == 1) {
			if(pay_type == 'cash') {
				var tip = '该定单为现金支付, 取消定单需要商家自己处理退款, 确定取消定单吗';
			} else if(pay_type != 'delivery') {
				var tip = '该定单为线上支付, 取消定单将发起退款流程, 确定取消定单吗';
			}
		}
		if(!confirm(tip)) {
			e.preventDefault();
		}
		return true;


});
</script>
{elseif $op == 'show'}
<form class="form-horizontal" role="form">
	<div class="page-trade-order">
		<div class="order-list">
			<div class="freight-content">
				<div class="freight-template-item panel panel-default">
					<div class="panel-body clearfix">
						<div class="col-xs-12 col-sm-6 order-infos">
							<h4>定单信息</h4>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">定单编号：</label>
								<div class="col-md-9 form-control-static">
									{$order['ordersn']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">所属类型：</label>
								<div class="col-md-9 form-control-static">
									{if $order['ordertype']=='special'}
									<span class="label label-info">专题</span>
							{elseif $order['ordertype']=='activity'}
									<span class="label label-primary">活动</span>
							{elseif $order['ordertype']=='buy'}
									<span class="label label-primary">商品</span>
							{elseif $order['ordertype']=='scanpay'}
									<span class="label label-primary">扫码支付</span>
									{else}
									<span class="label label-warning">其他</span>
									{/if}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">客户信息：</label>
								<div class="col-md-9 form-control-static">
									{$order['username']} {$order['mobile']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">下单时间：</label>
								<div class="col-md-9 form-control-static">
									{php echo date('Y-m-d H:i:s', $order['addtime']);}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">定单状态：</label>
								<div class="col-md-9 form-control-static">
									{if $order['status']=='0'}
									<span class="label label-warning">未支付</span>
								{elseif $order['status']=='1'}
									<span class="label label-success">未核销</span>
								{elseif $order['status']=='2'}
									<span class="label label-primary">已核销</span>
								{else}
									<span class="label label-warning">其他</span>
								{/if}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">定单价格：</label>
								<div class="col-md-9 form-control-static">
									￥ {$order['orderfee']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">实际支付：</label>
								<div class="col-md-9 form-control-static">
									￥ {$order['realfee']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">卡券使用：</label>
								<div class="col-md-9 form-control-static">
									{if $row['usecard']==0}
							<span class="label label-info">未使用</span>
							{else}
							<span class="label label-primary">已使用</span>
							{/if}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">付款方式：</label>
								<div class="col-md-9 form-control-static">
									{if !$order['paystate']}
										<span class="label label-danger">未支付</span>
									{else}
										{if $order['type']=='credit'}
											<span class="label label-info">余额支付</span>
											{elseif $order['type']=='wechat'}
											<span class="label label-success">微信支付</span>
											{elseif $order['type']=='delivery'}
											<span class="label label-primary">货到付款</span>
											{else}
											<span class="label label-warning">其他方式</span>
											{/if}
									{/if}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">付款时间：</label>
								<div class="col-md-9 form-control-static">
									{php echo date('Y-m-d H:i:s', $order['paytime']);}
								</div>
							</div>
							
							
						</div>
{if $order['ordertype']=='special'}
						<div class="col-xs-12 col-sm-6">
							<h4>所属专题</h4>
							
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">专题名称：</label>
								<div class="col-md-9 form-control-static">
									{$goods['special']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">购买商品：</label>
								<div class="col-md-9 form-control-static">
									{$goods['title']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">商品数量：</label>
								<div class="col-md-9 form-control-static">
									{$goods['count']}
								</div>
							</div>
														<div class="form-group clearfix">
								<label class="col-md-3 control-label">收货人：</label>
								<div class="col-md-9 form-control-static">
									{$goods['dzusername']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">电话：</label>
								<div class="col-md-9 form-control-static">
									{$goods['dzmobile']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">地址：</label>
								<div class="col-md-9 form-control-static">
									{$goods['dzaddress']}
								</div>
							</div>
						</div>
{elseif $order['ordertype']=='activity'}
						<div class="col-xs-12 col-sm-6">
							<h4>所属活动</h4>
							
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">活动名称：</label>
								<div class="col-md-9 form-control-static">
									{$activity['title']}
								</div>
							</div>
							{loop $liaisons $item}
							
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">报名人信息：</label>
								<div class="col-md-9 form-control-static">
									{$item['username']} {$item['mobile']} 
								</div>
							</div>
							
							{/loop}
						</div>
{elseif $order['ordertype']=='buy'}
						<div class="col-xs-12 col-sm-6">
							<h4>商品信息</h4>
							
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">商品名称：</label>
								<div class="col-md-9 form-control-static">
									{$goods['title']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">商品数量：</label>
								<div class="col-md-9 form-control-static">
									{$goods['count']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">收货人：</label>
								<div class="col-md-9 form-control-static">
									{$goods['dzusername']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">电话：</label>
								<div class="col-md-9 form-control-static">
									{$goods['dzmobile']}
								</div>
							</div>
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">地址：</label>
								<div class="col-md-9 form-control-static">
									{$goods['dzaddress']}
								</div>
							</div>
						</div>
{elseif $order['ordertype']=='scanpay'}
						<div class="col-xs-12 col-sm-6">
							<h4>商户信息</h4>
							
							<div class="form-group clearfix">
								<label class="col-md-3 control-label">商户名称：</label>
								<div class="col-md-9 form-control-static">
									{$shop['title']}
								</div>
							</div>
						</div>
{else}
其他
{/if}

						
						
						
						
					</div>
				</div>
			</div>
		</div>
	</div>
</form>
{/if}
